<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册</title>
    <script>
        function doCheck(){
            let loginName=document.querySelector("input[name=loginName]").value;
            if(!loginName||!loginName.trim()){
                alert("登录名不能为空");
                return false;
            }
            let password=document.querySelector("input[name=password]").value;
            let rePassword=document.querySelector("input[name=rePassword]").value;
            if(password!=rePassword){
                alert("两次密码不一致");
                return false;
            }

            return true;
        }
    </script>
</head>
<body>
    <h2>注册</h2>
    <?php
    $msg=$_REQUEST["msg"];
    ?>
    <div style="height：30px;color:red;font-size:12px;"><?= $msg ?></div>
    <form action="/day04/register.php" method="post" onsubmit="return doCheck()">
        <div>
            <label>登录名:<input type="text" name="loginName"></label>
        </div>
        <div>
            <label>密码:<input type="password" name="password"></label>
        </div>
        <div>
            <label>确认密码:<input type="password" name="rePassword"></label>
        </div>
        <div>
            <label>爱好:</label>
            <label><input type="checkbox" name="hobby[]" value="1">吃饭</label>
            <label><input type="checkbox" name="hobby[]" value="2">睡觉</label>
            <label><input type="checkbox" name="hobby[]" value="3">打豆豆</label>
        </div>
        <div>
            <input type="submit" value="注册">
        </div>
    </form>
</body>
</html>



